home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / mini / Coffee < prev    next >
Encoding:
Text File  |  1997-02-12  |  14.5 KB  |  381 lines

  1.   COFFEE-HOWTO
  2.   Georgatos Photis, <gef@ceid.upatras.gr>
  3.   v0.5, 15-01-1998
  4.  
  5.   One of the most bothering remarks on software, I have ever heard, is
  6.   weather this or that thing can make coffee.  So, Linux DOES make cof¡
  7.   fee. And it tastes good, instead!
  8.  
  9.   For a long time, humanity was wondering how could a computer make
  10.   coffee...  People need coffee to get awake and stay asleep in front of
  11.   the computer for a long time.  Everyone knows that coding is better at
  12.   night...
  13.  
  14.   The main problem is how to control the coffee machine with the
  15.   computer, so that it will be controlled by software.  This generally
  16.   means an ON/OFF switch implemented as a circuit which controls the
  17.   coffee-machine's power supply.
  18.  
  19.   1.  Menu
  20.  
  21.   1.1.  French
  22.  
  23.   Popular coffe among programmers because doesn't need a lot of care,
  24.   like all commercial software.  Its exciting taste has inspired
  25.   thousands of programmers in writing incredible software, written in
  26.   the very first ours of a day.  Windows for example are written at 5:00
  27.   o'clock in the morning, favouring to this coffee! Result is
  28.   guaranteed.
  29.  
  30.   1.2.  Nescaffe
  31.  
  32.   Nescaffe is a rather strong coffee, made by pouring hot water in a
  33.   mixture of coffee, sugar and some water.  You usually take 1 spoon of
  34.   coffee and 1 spoon of sugar with just a bit of water, to mix it. In
  35.   the meantime you should have the water boiling. As soon as the water
  36.   is hot enough, you mix them all together and preferably add milk.
  37.   Although you can use something simpler than a coffee-machine to boil
  38.   the water, I have seen this scheme a lot of times...
  39.  
  40.   1.3.  frappe
  41.  
  42.   Popular variation of the above mentioned coffee.  Actually, it doesn't
  43.   need any coffee-machine, rather a refridgerator to get cold water and
  44.   ice-cubes.
  45.  
  46.   1.4.  freddo
  47.  
  48.   This is a difficult one, read coffee-faq (see references)
  49.  
  50.   1.5.  cappuccino (To be added)
  51.  
  52.   1.6.  (To be added) espresso
  53.  
  54.   2.  Electronic circuit
  55.  
  56.   A general diagram is like this:
  57.  
  58.   --------- 0-5V  --------- ~220V  ----------------
  59.   |  PC   |===>===|Circuit|========|Coffee-Machine|
  60.   ---------       ---------        ----------------
  61.  
  62.   The concept is that we take a controling voltage from the computer,
  63.   which drives an electrically isolated circuit with Relay or Triac.
  64.  
  65.   You must choose a Relay circuit, if you have a big coffee-machine
  66.   (greater than 200W or so), otherwise you can use a triac-based one.
  67.  
  68.   All circuits presented are at least once tested, but it's YOURS
  69.   RESPONSIBILITY the results.  If you have no experience with
  70.   electronics you should NOT try with these, otherwise you may get a bad
  71.   one...
  72.  
  73.   You should be very careful while experimenting with 220V, and there is
  74.   no obsolence in using an appropriate fuse.
  75.  
  76.   2.1.  Driving voltage 0-5V from the computer
  77.  
  78.   Here is a simple example to get a voltage 0-5V from the parallel port
  79.   of the computer.
  80.  
  81.              Back View          -----    Pin 10 - ACK
  82.              Male DB-25         |   |    Pin  9 - D7
  83.              Connector          |   |                           Pin 2 - D0
  84.                                 v   v                           v   Pin 1 -
  85.        ~Strobe
  86.               ____________________________________________________________
  87.              /                                                            \
  88.              \     13  12  11  10   9   8   7   6   5   4   3   2   1     /
  89.               \                                                          /
  90.                \     25  24  23  22  21  20  19  18  17  16  15  14     /
  91.                 \______________________________________________________/
  92.  
  93.   Pin 1 is Strobe (inverse logic)
  94.  
  95.   Pins 2-9 is DATA BUS's signals, exactly what was written to the
  96.   parallel port's latches with an OUTB command.
  97.  
  98.   Pin 10 is the acknowledge signal (ACK), controlled by you, so that you
  99.   can produce an interrupt to the CPU.
  100.  
  101.   Pins 18-25 are short-circuited and this is the ground (GND).
  102.  
  103.   In detail:
  104.  
  105.   <= in   DB25    Cent    Name of         Reg
  106.   => out  pin     pin     Signal          Bit     Function Notes
  107.   ------  ----    ----    --------        ---     -----------------------------
  108.   =>       1       1      -Strobe         C0-     Set Low pulse >0.5 us to send
  109.   =>       2       2      Data 0          D0      Set to least significant data
  110.   =>       3       3      Data 1          D1      ...
  111.   =>       4       4      Data 2          D2      ...
  112.   =>       5       5      Data 3          D3      ...
  113.   =>       6       6      Data 4          D4      ...
  114.   =>       7       7      Data 5          D5      ...
  115.   =>       8       8      Data 6          D6      ...
  116.   =>       9       9      Data 7          D7      Set to most significant data
  117.   <=      10      10      -Ack            S6+ IRQ Low Pulse ~ 5 uS, after accept
  118.   <=      11      11      +Busy           S7-     High for Busy/Offline/Error
  119.   <=      12      12      +PaperEnd       S5+     High for out of paper
  120.   <=      13      13      +SelectIn       S4+     High for printer selected
  121.   =>      14      14      -AutoFd         C1-     Set Low to autofeed one line
  122.   <=      15      32      -Error          S3+     Low for Error/Offline/PaperEnd
  123.   =>      16      31      -Init           C2+     Set Low pulse > 50uS to init
  124.   =>      17      36      -Select         C3-     Set Low to select printer
  125.   ==      18-25   19-30,  Ground
  126.  
  127.   2.2.  Controlling with a Relay
  128.  
  129.   The simplest circuit that somebody can build is:
  130.  
  131.                                     Vcc
  132.                                      |
  133.                                      +------+
  134.                                      |    __|__
  135.                                    Relay   /^\  Diode 1N4002
  136.                                     Coil  /---\
  137.                                      |      |
  138.                                      +------+
  139.                                      |
  140.                                   | /
  141.                         4.7K    B |/  C
  142.        parallel port >-\/\/\/\/---|        NPN Transistor: BC547A or 2N2222A
  143.        data pi                    |\  E
  144.                                   | V
  145.                                     |
  146.        parallel port >--------------+
  147.        ground pin                   |
  148.                                  Ground
  149.  
  150.   Connect Vcc with the same voltage as the relay type (usually 5 or
  151.   12V).  Obviously, the relay's specifications should be reasonable for
  152.   your coffee-machine.
  153.  
  154.   Barmen, usually, tend to put the relay AFTER the transistor, at the
  155.   emitter (E) pin instead of the collector (C) pin. This is a bad
  156.   practice because it biases the transistor badly, and may result in bad
  157.   coffee :-).  Diode 1N4002 is useful to protect the transistor from the
  158.   relay's currents.  If you don't use it the transistor will become
  159.   darker and smelling...
  160.  
  161.   2.3.  Controlling with TRIAC #1
  162.  
  163.   If you only want a simple circuit, you can use Motorola's triac driver
  164.   MOC301012, together with a general purpose TRIAC like SC141D.  This
  165.   method has the advantage that you don't need an extra power supply.
  166.  
  167.   For non-inductive loads this is the circuitry:
  168.  
  169.                270     1 +-------+ 6    180
  170.          +5v -VAVAVA-----+       +----VAVAVA-----+-------------- Line Hot
  171.                        2 |  MOC  |               |
  172.          TTL in ---------+ 3012  +nc            VA  SC141D
  173.                          |       | 4           / |
  174.                        nc+       +------------/  |
  175.                          +-------+               +----\/\/\/---- Line Neutral
  176.                                                        LOAD
  177.  
  178.   If you are going to work with 220V, prefer a 3021.  Inductive loads
  179.   should be used in conjuction with bypass capacitors, see Motorola
  180.   Application Note AN-780.  Coffee-machines are mainly resistive loads
  181.   and not inductive (like a motor), but who knows what's yours...
  182.  
  183.   2.4.  Controlling with TRIAC #2
  184.  
  185.        +5VDC
  186.        |    180                      180            2.2k
  187.        +---/\/\/\----+-----+   +----/\/\/-+--/\/\/\---+-------> 120V
  188.                      |    1|   |6         |           |         Hot
  189.                      |    +=====+         |           | MT1
  190.                      |    | MC  | TRIAC   |          +-+
  191.                      |    | 3032| Driver  |        G | | TRIAC
  192.                      |    +=====+         |         /| |
  193.                      \    2|   |4         |        / +-+
  194.               2N3904  |----+   |          |        |  | MT2
  195.                      /     |   +--------- | -------+  |
  196.                     V      \              |        |  |
  197.                     |      /              |        \  |
  198.                     |      \ 43    .01u  ---   10k /  |
  199.                     |      /       500V  ---       \  |
  200.                     |      |              |        /  |
  201.                     +------+              |        |  |            Neutral
  202.                     |                     +--------+--+---o    o--> 120V
  203.                     /                                      load
  204.         >-/\/\--|  2N3904
  205.                     \
  206.                      V
  207.                      |
  208.                     ---
  209.                    ///
  210.        You should change resistors accordingly for 220V.
  211.  
  212.   Circuit description:
  213.  
  214.   The MC3032 is an optoisolator TRIAC driver.  The 180-ohm resistor sets
  215.   the current for the LED emitter in the optoisolator.  Change the value
  216.   of this resistor - if necessary - to get reasonable current (e.g., 15
  217.   mA).
  218.  
  219.   Note that you cannot test this circuit without a load.  The TRIAC will
  220.   not switch unless connected to an AC voltage source, so you can't test
  221.   it for simple switching w/o applying AC and a load. Note the 500V
  222.   rating on the .01 cap.
  223.  
  224.   3.  Software
  225.  
  226.   3.1.  Software
  227.  
  228.   You will have to build an executable that will perform like this:
  229.  
  230.   ╖  Get permissions to use I/O address space, by calling kernel, with
  231.      the command ioperm: eg ioperm( BASE, range ,1);
  232.  
  233.   ╖  Perform an out request instruction, to set the 0-5V voltage to the
  234.      parallel port, eg outb( 1, BASE );
  235.  
  236.   ╖  Wait for enough time so that coffee gets ready. It would be nice if
  237.      that time is read by looking at the command line.
  238.  
  239.   ╖  Then it will turn off the coffee-machine: outb( 0 , BASE );
  240.  
  241.   ╖  Before ending it should give back the paraller port with a ioperm(
  242.      BASE, range, 0);
  243.  
  244.      Change BASE = 0x3bc for /dev/lp0, 0x378 for /dev/lp1, and 0x278 for
  245.      /dev/lp2, range=8.
  246.  
  247.   It would be nice if you had that program setuid, so that everybody can
  248.   drink coffee!
  249.  
  250.   3.2.  Device driver
  251.  
  252.   Just read kernel hacker's guide, implement a device driver (it could
  253.   even be user space i think).  Please, compile it as a module, so that
  254.   we won't need a kernel compile in every update.  Then write:
  255.  
  256.   echo cappuccino >/dev/coffee
  257.  
  258.   And you will have a hot cup of coffee in 1 minute.  Remember to give
  259.   the right permission to /dev/coffee, depending on whether you want
  260.   only root making coffee or not.
  261.  
  262.   The advantage of this method is that it supports feedback from the
  263.   coffee-machine by using the ACK of parallel port, so that smart
  264.   coffee-machines could produce an interrupt.
  265.  
  266.   Do it as homework.
  267.  
  268.   3.3.  Connecting with the Internet
  269.  
  270.   If you have implemented the C programme (see above), you just have to
  271.   write down a simple CGI script to turn ON and OFF the coffee-machine.
  272.   You should write some nice webpages, explaining how to make coffee,
  273.   and put them at an apache web server...
  274.  
  275.   4.  Overdose symptoms
  276.  
  277.   ╖  excitement
  278.  
  279.   ╖  nervousness
  280.  
  281.   ╖  insomnia
  282.  
  283.   ╖  tachycardia or cardiac arhythmia
  284.  
  285.   ╖  gastrointestinal disturbance
  286.  
  287.   ╖  restlessness
  288.  
  289.   5.  Expansions
  290.  
  291.   These are our ideas:
  292.  
  293.   ╖  All hardware and software described here, can be expanded so that
  294.      it will support toast, beaf, applepies, etc.
  295.  
  296.   ╖  Cluster with 8 coffee-machines. This will let you have coffee even
  297.      when the one gets off. Of course there will be a perfomance hit.
  298.  
  299.   ╖  Parallel vector coffee-machine will be a future release.
  300.  
  301.   ╖  If you want the maximum automation you'll need more circuits and
  302.      censors, so that you can control water flow, temperature, coffee
  303.      quantity etc.
  304.  
  305.   ╖  In the near future we will implement SNMP features.
  306.  
  307.   ╖  Serial coffee-machine at 115Kbps.
  308.  
  309.   6.  References
  310.  
  311.   ╖  http://daisy.uwaterloo.ca/~alopez-o/caffaq.html This is Internet's
  312.      Coffee-FAQ
  313.  
  314.   ╖  http://lonestar.texas.net/~andrew/f_pc_.htm A lot of circuits in
  315.      ASCII. Some of them are for parallel port.
  316.  
  317.   ╖  http://shell.rmi.net/~hisys/parport.html Whatever you wanted to
  318.      learn about a parallel port and didn't dare to ask.
  319.  
  320.   ╖  http://sunsite.unc.edu/LDP/HOWTO/mini/IO-Port-Programming
  321.      Programming of I/O ports under popular operating system Linux.
  322.  
  323.   ╖  http://www.redhat.com:8080/HyperNews/get/khg.html How to write your
  324.      own device drivers. Come on, do it!
  325.  
  326.   ╖  http://www.hut.fi/Misc/Electronics/circuits/parallel_output.html
  327.      Tomi Engdahl's web page is a *must see* for everyone who likes
  328.      electronics.
  329.   ╖  http://www.yahoo.com/Computers_and_Internet/Internet/
  330.      Entertainment/Interesting_Devices_Connected_to_the_Net/Coffee_Machines/
  331.      Coffee-machines on-line. Unfortunatelly, there are no tests.
  332.  
  333.   ╖  http://www.cs.su.oz.au/~bob/coffee.html This coffee-machine offers
  334.      only cappuccino. It should be upgraded!
  335.  
  336.   ╖  http://einstein.et.tudelft.nl/~janssen/ Hot coffee from
  337.      Netherlands.
  338.  
  339.   ╖  http://circe.chinalake.navy.mil/cgi-bin/spion/snapit.cgi
  340.  
  341.   ╖  http://www.cl.cam.ac.uk/coffee/coffee.html
  342.  
  343.   ╖  http://www.menet.umn.edu/coffeecam/
  344.  
  345.   7.  etc
  346.  
  347.   7.1.  preface
  348.  
  349.   This document was initially written in hellenic (greek), originating
  350.   from a small debate in the linux-greek-users list , whether linux can
  351.   make coffee or not.  It has been an article in our beautiful online
  352.   magazine on Linux called "magaz": http://www.linux.gr/magaz.
  353.   Remember, that magaz is greek.
  354.  
  355.   7.2.  Authorship and maintenance
  356.  
  357.   My name is Georgatos Photis, still-yet-foralongmaybe student at
  358.   Computer Engineering and Informatics department in University of
  359.   Patras.  Usually, I am pretty busy with the greek documentation and
  360.   webpages maintainance, but I can accept submissions to this HOWTO, as
  361.   long as you don't be anxious on the changes.
  362.  
  363.   7.3.  Copyrights
  364.  
  365.   The casual copyright with everything you get with linux...  To find
  366.   it, you'll have to read all of them and count the most common.
  367.   Otherwise, no, you can't copy it.
  368.  
  369.   7.4.  Credits
  370.  
  371.   ╖  Christofer Colombus. His real name is Cristobal Colon.  He was the
  372.      1st one who brought coffee from America, which was for first
  373.      discovered (among Europeans) by him in 1492.
  374.  
  375.   ╖  Kostas Lialiambis is the one who dared saying that he can't make
  376.      coffee with his Linux box!
  377.  
  378.   ╖  Panagiotis Vrionis, Yannakopoulos Haralambos, for giving me
  379.      interesting and humoristing notes.
  380.  
  381.